package com.heima.ssm.controller;

import com.heima.ssm.pojo.User;
import com.heima.ssm.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;

import javax.management.loading.MLet;

/**
 * @package com.heima.ssm
 * @description:
 * @author: 86157
 * @date 2019/6/3 17:09
 * @version: V1.0
 */

@Controller
@RequestMapping("user")
public class controller {

    @Autowired
    private UserService userService;

    @RequestMapping("showuser")
    public String toUser(Model model, @RequestParam("id") Long id) {
        User user = userService.findUserById(1L);
        model.addAttribute("user", user);
        return "user";
    }

    @RequestMapping("deleteuser")
    @ResponseStatus(HttpStatus.OK)
    public void deleteUser(Model model, @RequestParam("id") Long id) {
        userService.deleteUserById(id);
    }


}